<?php include './admin/view/header.inc.htm'; ?>

<div class="panel">
	<div class="header">创建文章</div>
	<div class="body">
		<form method="POST" id="form" action="admin/article-create-<?php echo $articleid; ?>.htm">
			<table class="form">
				<tr>
					<th><span class="red">*</span> 文章分类</th>
					<td>
						<select name="cateid" id="cateid">
						<?php foreach($conf['cate'] as $cateid=>$catename) { ?>
							<option value="<?php echo $cateid; ?>"><?php echo $catename; ?></option>
						<?php } ?>
						</select>
					</td>
				</tr>
				<tr>
					<th><span class="red">*</span> 标题</th>
					<td><input type="text" name="subject" id="subject"/></td>
				</tr>
				<tr>
					<th><span class="red">*</span> 内容</th>
					<td><textarea name="message" id="message" rows="8" style="width: 800px; height: 300px;"></textarea></td>
				</tr>
				<tr>
					<th>简介</th>
					<td><textarea name="brief" rows="3"></textarea></td>
				</tr>
				<tr>
					<th>SEO</th>
					<td><input type="text" name="seo_title" /></td>
				</tr>
				<tr>
					<th>关键词</th>
					<td><input type="text" name="seo_keywords" /></td>
				</tr>
				<tr>
					<th>描述</th>
					<td><input type="text" name="seo_description" /></td>
				</tr>
				<tr>
					<th>&nbsp;</th>
					<td><button type="submit" id="submit" loading-text="正在提交..." class="blue big">确定</button></td>
				</tr>
			</table>
		</form>
	</div>
</div>

<?php include './admin/view/footer.inc.htm'; ?>

<link rel="stylesheet" type="text/css" href="xneditor/editor.css" />
<script src="xneditor/editor.js"></script>
<script>
var editor = new $.XNEditor({textarea: 'message', image_upload_url:'admin/article-upload.htm', image_upload_width: <?php echo $conf['upload_image_width']; ?>, file_upload_url:'admin/article-upload.htm'});
var jform = $("#form");
var jsubject = $("#subject");
var jcateid = $("#cateid");
var jsubmit = $("#submit");
var jmessage = $('#message');

jform.on('submit', function(){
	var postdata = jform.serialize();
	jsubmit.button('loading');
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			jsubmit.text(message);
			setTimeout(function(){
				window.location = 'admin/article-list.htm';
			}, 2000);
			return;
		} else if(code == 1) {
			jcateid.popover(message).focus();
		} else if(code == 2) {
			jsubject.popover(message).focus();
		} else if(code == 3) {
			editor.jeditor.popover(message).focus();
		} else {
			$.alert(message);
		}
		jsubmit.button('reset');
	});
	return false;
});
</script>